﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;
using RooHui.Infrastructure.Entities.Enum;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class MemberLog : IAccessible<P_MemberLog, MemberLog>, ILogicEntity<P_MemberLog, MemberLog>
    {
        public int ID { get; set; }
        public string UserName { get; set; }
        public MemberOperateType OperateType { get; set; }
        public string OperateIP { get; set; }
        public string OperateContent { get; set; }
        public DateTime OperateTime { get; set; }

        protected override void Covariant(P_MemberLog model)
        {
            if (model != null)
            {
                this.ID = model.ID;
                this.OperateContent = model.OperateContent;
                this.OperateIP = model.OperateIP;
                this.OperateTime = model.OperateTime;
                this.OperateType = (MemberOperateType)model.OperateType;
                this.UserName = model.UserName;
            }
        }

        protected override P_MemberLog Inverter(MemberLog model)
        {
            if (model != null)
            {
                return new P_MemberLog()
                {
                    ID = model.ID,
                    OperateContent = model.OperateContent,
                    OperateIP = model.OperateIP,
                    OperateTime = model.OperateTime,
                    OperateType = (int)model.OperateType,
                    UserName = model.UserName
                };
            }
            return null;
        }

        public MemberLog Set(P_MemberLog dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
